package com.npy.reggie.service.Imlp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.npy.reggie.doman.AddressBook;
import com.npy.reggie.mapper.AddressBookMapper;

import com.npy.reggie.service.AddressBookService;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class AddressBookServiceImpl extends ServiceImpl<AddressBookMapper, AddressBook> implements AddressBookService {
    @Override
    @Transactional
    public void updateDefaultValue(Long id) {
        QueryWrapper<AddressBook> queryWrapper = new QueryWrapper<AddressBook>();

        queryWrapper.lambda().eq(id != -1,AddressBook::getId,id);

        AddressBook addressBook = new AddressBook();

        addressBook.setIsDefault(0);

        update(addressBook,queryWrapper);
    }
}
